#include <stdio.h>
#include <stdlib.h>	/* exit() */
#include <string.h>
#include <pthread.h>
#include <sys/time.h>
#include <time.h>
#include <limits.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>


/*
 * exec 函数.
 */

char *env_init[] = {"USER=unknown", "PATH=/tmp", NULL};

int main()
{
	pid_t pid;

	if (( pid = fork()) < 0)
		perror("fork error");
	else if (pid == 0) {
		if (execle("/home/bin/echoall", "echoall", "myarg1",
			"MY_ARG2", (char *) 0, env_init) < 0)
			perror("execle error");
	}

	if (waitpid(pid, NULL, 0) < 0)
		perror("wait error");

	if ((pid = fork()) < 0)
		perror("fork error");
	else if (pid == 0) {
		if (execlp("echoall", "echoall", "only 1 arg", (char *) 0) < 0)
			perror("execlp error");
	}

	exit(0);
}


